//
//  ZLMainNavigationController.swift
//  MVVM微博
//
//  Created by AppleDev on 2017/7/15.
//  Copyright © 2017年 AppleDev. All rights reserved.
//

import UIKit

class ZLMainNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

      navigationBar.isHidden = true
    }


    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if childViewControllers.count > 0 {
            
            viewController.hidesBottomBarWhenPushed = true
            
        }
        
        if let vc = viewController as? ZLBaseViewController {
            
            var title = "返回"
            
            if childViewControllers.count == 1 {
                
                title = childViewControllers.first?.title ?? "返回"
                
            }
            vc.item.leftBarButtonItem = UIBarButtonItem(title: title, fontSize: 16, target: self, action: #selector(popToParent), isBack:true)
        }
        
        super.pushViewController(viewController, animated: true)
    }
    
    func popToParent(){
        
        popViewController(animated: true)
        
    }
    
    
}
